package aop.example;


import aop.annotation.Aspect;
import aop.annotation.Component;
import aop.annotation.PointCut;
import aop.annotation.PointCutType;

@Component
@Aspect
public class LoggingAspect {

  // 前置通知
  @PointCut(type= PointCutType.BEFORE,
            cut="public int aop.example.Calculator.add(int, int); " +
                "public void aop.example.Greeter.sayHello(java.lang.String);")

  //静态
  public static void logBefore() {
    System.out.println("静态方法前置通知");
  }

  // 后置通知
  @PointCut(type=PointCutType.AFTER,
            cut="public long aop.example.Calculator.add(int, int); " +
                "public void aop.example.Greeter.sayHello(java.lang.String)")
  //静态
  public static void logAfter() {
    System.out.println("静态方法后置通知");
  }

  // 后置通知
  @PointCut(type=PointCutType.AFTER,
            cut="public int aop.example.Calculator.add(int, int);" +
                "public void aop.example.Greeter.sayHello(java.lang.String);")
  //非静态
  public void logAfter2() {
    System.out.println("非静态方法后置通知");
  }

}
